package kata06;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Arrange {

    public static List<String> getAllSort(String wordStr) {
        List<String> result = new ArrayList<>();
        allSort(wordStr.toCharArray(), 0, result);
        return result;
    }

    private static void allSort(char[] arr, int index, List<String> result) {
        if (index == arr.length) {
            result.add(String.valueOf(arr));
            return;
        }
        for (int i = index; i < arr.length; i++) {
            swap(arr, index, i);
            allSort(arr, index + 1, result);
            swap(arr, index, i);
        }
    }

    private static void swap(char[] arr, int i, int j) {
        char temp = arr[i];
        arr[i] = arr[j];
        arr[j] = temp;
    }
}